<?php

namespace app\api\controller;

use app\api\service\Base;
use app\common\model\AppMember;

/**
 * 捐款接口
 * Class App
 * @package app\api\controller
 */
class App extends Base
{
    /**
     * 捐款页面
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index()
    {
        $return['title'] = sysconf('page.title');
        $return['topic'] = sysconf('page.topic');
        $return['desc'] = sysconf('page.desc');
        $return['money_count'] = number_format(floatval((new AppMember())->moneyCount()), 0);
        $return['day'] = date("Y年m月d日");
        $return['money_setting'] = sysconf('page.money_setting');
        $this->success('查询成功', $return);
    }

    /**
     * 提交捐款信息
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function submit()
    {
        $this->response((new AppMember())->userSubmit($this->param));
    }

    /**
     * 捐款名单
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function list()
    {
        $page = $this->param['page'] ?? 1;
        $limit = $this->param['limit'] ?? 10;
        $this->success('查询成功', (new AppMember())->list([], 'id desc', $page, $limit));
    }
}